extends "../yilishabai-2/yilishabai-2.gd"

func _extInit():
	._extInit()
	lv = 3             #等级的设置
	addSkill("<唯一>连接所有皇家阵营的舰娘，任何被连接成员阵亡，均会使其他所有链接成员获得10层<振奋>并获得[血上限30%]的护盾", "皇家舰队")

var connChas = []
func _onBattleStart():
	._onBattleStart()
	connChas.append(self)
	for i in getAllChas(2):
		if i.get("camp") == "皇家" and i != self:
			utils.createSkillTextEff("皇家舰队", i.position)
			connChas.append(i)
	if team == 1:
		for i in connChas:
			if i.hasBuff("b_royalFleet") == null:
				i.addBuff(b_royalFleet.new(connChas))
	else:
		for i in connChas:
			i.addBuff(buff.b_zhenFen.new(10))

class b_royalFleet:
	extends "../../../../azurlane_ctrl/AzurBuff.gd"
	var connChas = []
	func _init(connChas = []):
		attInit()
		id = "b_royalFleet"	
		self.connChas = connChas
		buffName = "皇家舰队"
		dispel = 2
	func _connect():
		masCha.connect("onDeath",self,"_onDeath")
	func _onDeath(atkInfo):
		if connChas.size() < 2 or not masCha.isDeath:return
		connChas.erase(masCha)
		for i in connChas:
			var bf = i.hasBuff("b_royalFleet")
			if i != masCha and bf != null and not i.isDeath:
				i.addBuff(buff.b_zhenFen.new(10))
				i.changeShield(masCha.att.maxHp*0.3)
				bf.connChas.erase(masCha)
		masCha.delBuff(masCha.hasBuff("b_royalFleet"))

func _onBattleEnd():
	._onBattleEnd()
	connChas.clear()